﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace Utils
{
    /// <summary>
    /// 加密工具类
    /// </summary>
    public class EncryptUtil
    {
        /// <summary>
        /// MD5加密
        /// </summary>
        /// <param name="encodeStr">需要加密的字符串</param>
        /// <returns>已经加密的字符串</returns>
        public static string Encode(string encodeStr)
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] fromData = Encoding.Unicode.GetBytes(encodeStr);
            byte[] toData = md5.ComputeHash(fromData);
            string byteStr =BitConverter.ToString(toData,4,8);
            byteStr=byteStr.Replace("-", "");
            return byteStr;
        }       
    }
}
